#include <Windows.h>
#include <cstring>
#include <iomanip>
#pragma comment(lib, "User32.lib")
namespace lx
{

    std::string rgb2hex(int r, int g, int b, bool with_head = false);
    std::string rgb2hex(int r, int g, int b, bool with_head)
    {
        std::stringstream ss;
        if (with_head)
            ss << "#";
        ss << std::hex << (r << 16 | g << 8 | b);
        return ss.str();
    }

    std::string getColor()
    {
        HWND hWnd = ::GetDesktopWindow();
        HDC hdc = ::GetDC(hWnd);
        COLORREF pixel = ::GetPixel(hdc, 150, 50);
        int red = GetRValue(pixel);
        int green = GetGValue(pixel);
        int blue = GetBValue(pixel);
        return rgb2hex(red, green, blue);
    }
}